home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / gotya.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  5KB  |  213 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4.  
  5. unsigned char *gotya_scroll;
  6. unsigned char *gotya_foregroundram;
  7.  
  8. static int scroll_bit_8,flipscreen;
  9.  
  10.  
  11. /***************************************************************************
  12.  
  13.   Convert the color PROMs into a more useable format.
  14.  
  15.   I'm using Pac Man resistor values
  16.  
  17. ***************************************************************************/
  18. void gotya_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  19. {
  20.     int i;
  21.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  22.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  23.  
  24.  
  25.     for (i = 0;i < Machine->drv->total_colors;i++)
  26.     {
  27.         int bit0,bit1,bit2;
  28.  
  29.  
  30.         /* red component */
  31.         bit0 = (*color_prom >> 0) & 0x01;
  32.         bit1 = (*color_prom >> 1) & 0x01;
  33.         bit2 = (*color_prom >> 2) & 0x01;
  34.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  35.         /* green component */
  36.         bit0 = (*color_prom >> 3) & 0x01;
  37.         bit1 = (*color_prom >> 4) & 0x01;
  38.         bit2 = (*color_prom >> 5) & 0x01;
  39.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  40.         /* blue component */
  41.         bit0 = 0;
  42.         bit1 = (*color_prom >> 6) & 0x01;
  43.         bit2 = (*color_prom >> 7) & 0x01;
  44.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  45.  
  46.         color_prom++;
  47.     }
  48.  
  49.     color_prom += 0x18;
  50.     /* color_prom now points to the beginning of the lookup table */
  51.  
  52.     /* character lookup table */
  53.     /* sprites use the same color lookup table as characters */
  54.     for (i = 0;i < TOTAL_COLORS(0);i++)
  55.         COLOR(0,i) = *(color_prom++) & 0x07;
  56. }
  57.  
  58.  
  59. WRITE_HANDLER( gotya_video_control_w )
  60. {
  61.     static int last;
  62.  
  63.     /* bit 0 - scroll bit 8
  64.        bit 1 - flip screen
  65.        bit 2 - sound disable ??? */
  66.  
  67.     scroll_bit_8 = data & 0x01;
  68.     flipscreen   = data & 0x02;
  69.  
  70.     if (flipscreen != (last & 0x02))
  71.     {
  72.         memset(dirtybuffer, 1, videoram_size);
  73.     }
  74.  
  75.     last = data;
  76. }
  77.  
  78.  
  79. int gotya_vh_start(void)
  80. {
  81.     if ((dirtybuffer = malloc(videoram_size)) == 0)
  82.     {
  83.         return 1;
  84.     }
  85.  
  86.     /* the background area is twice as wide as the screen (actually twice as tall, */
  87.     /* because this is a vertical game) */
  88.     if ((tmpbitmap = osd_create_bitmap(2*256,Machine->drv->screen_height)) == 0)
  89.     {
  90.         free(dirtybuffer);
  91.         return 1;
  92.     }
  93.  
  94.     return 0;
  95. }
  96.  
  97.  
  98. static void draw_status_row(struct osd_bitmap *bitmap, int sx, int col)
  99. {
  100.     int row;
  101.  
  102.     if (flipscreen)
  103.     {
  104.         sx = 35 - sx;
  105.     }
  106.  
  107.     for (row = 29;row >= 0;row--)
  108.     {
  109.         int sy;
  110.  
  111.         if (flipscreen)
  112.         {
  113.             sy = row;
  114.         }
  115.         else
  116.         {
  117.             sy = 31 - row;
  118.         }
  119.  
  120.         drawgfx(bitmap,Machine->gfx[0],
  121.                 gotya_foregroundram[row * 32 + col],
  122.                 gotya_foregroundram[row * 32 + col + 0x10] & 0x0f,
  123.                 flipscreen, flipscreen,
  124.                 8*sx,8*sy,
  125.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  126.     }
  127. }
  128.  
  129.  
  130. void gotya_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  131. {
  132.     int offs;
  133.  
  134.  
  135.     /* for every character in the Video RAM, check if it has been modified */
  136.     /* since last time and update it accordingly. */
  137.     for (offs = videoram_size - 1;offs >= 0;offs--)
  138.     {
  139.         if (dirtybuffer[offs])
  140.         {
  141.             int sx,sy;
  142.  
  143.  
  144.             dirtybuffer[offs] = 0;
  145.  
  146.             sx = 31 - (offs % 32);
  147.             sy = 31 - ((offs & 0x03ff) / 32);
  148.  
  149.             if (flipscreen)
  150.             {
  151.                 sx = 31 - sx;
  152.                 sy = 31 - sy;
  153.             }
  154.  
  155.             if (offs < 0x0400)
  156.             {
  157.                 sx = sx + 32;
  158.             }
  159.  
  160.             drawgfx(tmpbitmap,Machine->gfx[0],
  161.                     videoram[offs],
  162.                     colorram[offs] & 0x0f,
  163.                     flipscreen,flipscreen,
  164.                     8*sx, 8*sy,
  165.                     0,TRANSPARENCY_NONE,0);
  166.         }
  167.     }
  168.  
  169.  
  170.     /* copy the background graphics */
  171.     {
  172.         int scroll;
  173.  
  174.  
  175.         scroll = *gotya_scroll + (scroll_bit_8 * 256) + 16;
  176.  
  177.         copyscrollbitmap(bitmap,tmpbitmap,1,&scroll,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  178.     }
  179.  
  180.  
  181.     /* draw the sprites */
  182.     for (offs = 2; offs < 0x0e; offs += 2)
  183.     {
  184.         int code,col,sx,sy;
  185.  
  186.  
  187.         code = spriteram[offs + 0x01] >> 2;
  188.         col  = spriteram[offs + 0x11] & 0x0f;
  189.         sx   = 256 - spriteram[offs + 0x10] + (spriteram[offs + 0x01] & 0x01) * 256;
  190.         sy   =       spriteram[offs + 0x00];
  191.  
  192.         if (flipscreen)
  193.         {
  194.             sy = 240 - sy;
  195.         }
  196.  
  197.         drawgfx(bitmap,Machine->gfx[1],
  198.                 code,col,
  199.                 flipscreen,flipscreen,
  200.                 sx,sy,
  201.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  202.     }
  203.  
  204.  
  205.     /* draw the status lines */
  206.     draw_status_row(bitmap, 0,  1);
  207.     draw_status_row(bitmap, 1,  0);
  208.     draw_status_row(bitmap, 2,  2);        /* these two are blank, but I dont' know if the data comes */
  209.     draw_status_row(bitmap, 33, 13);    /* from RAM or 'hardcoded' into the hardware. Likely the latter */
  210.     draw_status_row(bitmap, 35, 14);
  211.     draw_status_row(bitmap, 34, 15);
  212. }
  213.